/*
 * SplashScreen.fx
 *
 * Created on 12-May-2010, 18:32:43
 */

package com.googlecode.snorkel;

import javafx.scene.Group;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.scene.CustomNode;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
import javafx.animation.Interpolator;
import javafx.scene.Node;

/**
 * @author brian
 */

public class SplashScreen extends CustomNode {
   // Create our splashScreen
   var opacityState = 1.0;
   var splashScreen =
      Group {
         content: [
            ImageView {
               image: Image {url: "{__DIR__}images/SNorkel_splash_screen_1.png"}
               smooth: true
               fitWidth: 800.0
               fitHeight: 600.0
               cache: true
            }
         ]
         opacity: bind opacityState
      };

   // Add the fading and public functions
   var fadeIn = Timeline {
      keyFrames : [
         KeyFrame {
            time: 2s
            values: [opacityState => 1.0 tween Interpolator.LINEAR]
         }
      ]
   }
   var fadeOut = Timeline {
      keyFrames : [
         KeyFrame {
            time: 2s
            values: [opacityState => 0.0 tween Interpolator.LINEAR]
         }
      ]
   }
   package function fadeInSplash(){fadeIn.playFromStart();}
   package function fadeOutSplash(){fadeOut.playFromStart();}

   // Show our Node
   override public function create(): Node {
      Group {
         content: [splashScreen]
      };
   }
}
